package com.jg.controller;

import com.jg.comm.responce.PageResult;
import com.jg.comm.responce.R;
import com.jg.model.entity.Squad;
import com.jg.service.SquadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 86130
 * @since 2025-10-22 10:25
 */
@RestController
@RequestMapping("/squad")
public class SquadController {

    @Autowired
    private SquadService squadService;
    /**
     * 获取所有小队信息
     *
     * @return
     */
    @GetMapping("list")
    public List<Squad> list() {
        List<Squad> list = squadService.listBYDesc();
        return list;
    }

    @PostMapping("add")
    public R add(Squad squad) {
        boolean save = squadService.save(squad);
        if (save) {
            return R.success("添加成功");
        }
        return R.success("添加失败");
    }
}
